import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 黎鹤舞
 * Date: 2023-11-25
 * Time: 9:06
 */


class Student {
    String name;
    int age;

    //构造方法:
    public Student(String name,int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "name:"+name+" age:"+age;
    }
}
public class Test {


    //字符串转化valueOf
    public static void main(String[] args) {

        //把int类型数据转化为字符串
        String str1 = String.valueOf(123);
        System.out.println(str1);

        int a = Integer.parseInt("123");
        System.out.println(a);

        //把Student类型(引用类型)转化为字符串
        Student student = new Student("张三",18);
        //方法一:默认情况下
        String str2 = String.valueOf(student);
        System.out.println(str2);


    }

    public static void main1(String[] args) {

        //String的不同定义
        String str1 = "hello";
        String str2 = new String("world");
        char[] chars = {'b','i','t','e','!'};

        //String打印的练习
        System.out.println(str1);
        System.out.println(str2);

        //字符串查找
        System.out.println(str1.charAt(0));
        //如果charAt内的数据为负数或者数组越界，会报错
//        System.out.println(str1.charAt(6));
    }
}
